﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using log4net;
using System.Reflection;

namespace AnyOffice.general.calendar.info
{
    public partial class delete :  ModulePage
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
       
 
        protected void Page_Load(object sender, EventArgs e)
        {
            int calId = (Request.QueryString["calid"] != null) ? int.Parse(Request.QueryString["calid"].ToString()) : 0;
            DateTime time = (Request.QueryString["date"] != null) ? DateTime.Parse(Request.QueryString["date"].ToString()) : DateTime.Now;
            string userId = (Request.QueryString["user_id"] != null) ? Request.QueryString["user_id"].ToString() : "";
            if (!SecurityManager.IsCanManage(userId))
            {
                base.CloseConn();
                Response.Write(base.ShowErrorNoNav("无权限"));
                Response.End();
            }
            new CalendarDao().Delete(base.Conn, calId, userId);
            this.litMessage.Text = base.ShowPromptClose("删除成功");
            DateTime time2 = new DateTime(2000, 1, 1);
            DateTime time3 = time;
            TimeSpan span = (TimeSpan)(time3 - time2);
            StringBuilder builder = new StringBuilder();
            builder.Append("<script Language=\"JavaScript\">");
            builder.Append("window.opener.__doPostBack('DataCalendar1','" + span.Days.ToString() + "');");
            builder.Append("</script>");
            if (!this.Page.IsClientScriptBlockRegistered("refresh"))
            {
                this.Page.RegisterClientScriptBlock("refresh", builder.ToString());
            }
        } 

    }
}
